﻿
@{
    ViewBag.Title = "编辑延迟任务";
    var m = ViewBag.m as DelayTask;
}

<form class="layui-form" id="frm" style="width:600px;">
    <input type="hidden" value="@m.Id" name="id" />
    <div class="layui-form-item">
        <label class="layui-form-label">任务名称：</label>
        <div class="layui-input-block">
            <input type="text" name="Name" value="@m.Name" required lay-verify="required" placeholder="任务名称" class="layui-input" />
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">任务地址：</label>
        <div class="layui-input-block">
            <input type="text" name="Url" value="@m.Url" required lay-verify="required" placeholder="任务地址" class="layui-input" />
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">请求方法：</label>
        <div class="layui-input-block">
            <input type="text" name="Method" value="@m.Method" required lay-verify="required" placeholder="请求方式GET或POST" class="layui-input" />
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">Post数据：</label>
        <div class="layui-input-block">
            <textarea class="layui-textarea" name="PostData">@m.PostData</textarea>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">触发时间：</label>
        <div class="layui-input-block">
            <input type="text" name="TriggerTime" id="TriggerTime" value="@(m.TriggerTime== DateTime.MinValue?"":m.TriggerTime.ToString("yyyy-MM-dd HH:mm:ss"))" placeholder="成功标识" class="layui-input" />
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">成功标识：</label>
        <div class="layui-input-block">
            <input type="text" name="SuccessFlag" value="@m.SuccessFlag" placeholder="成功标识" class="layui-input" />
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">超时秒数：</label>
        <div class="layui-input-block">
            <input type="text" name="TimeoutSeconds" value="@m.TimeoutSeconds" required lay-verify="required" placeholder="请求超时秒数" class="layui-input" />
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">重试次数：</label>
        <div class="layui-input-block">
            <input type="text" name="MaxRetryCount" value="@m.MaxRetryCount" required lay-verify="required" placeholder="请求超时秒数" class="layui-input" />
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">延迟秒数：</label>
        <div class="layui-input-block">
            <input type="text" name="RetrySeconds" value="@m.RetrySeconds" required lay-verify="required" placeholder="请求超时秒数" class="layui-input" />
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">状态：</label>
        <div class="layui-input-block">
            <input type="checkbox" @(m.Enable ? "checked" : "") name="Enable" value="true" lay-skin="switch" lay-filter="switchTest" lay-text="开启|禁用">
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button type="button" class="layui-btn" lay-submit lay-filter="btnSubmit">保存</button>
            <a class="layui-btn layui-btn-primary " href="@Url.Action("list")">取消</a>
        </div>
    </div>
</form>


@section scripts{
    <script>

        layui.laydate.render({ elem: "#TriggerTime", type: 'datetime' });
           //监听提交
        layui.form.on('submit(btnSubmit)', function (data) {
            $.post("@Url.Action("doedit")", data.field, function (ro) {
                alert(ro.Msg);
                if (ro.Success) {
                    location.href = '@Url.Action("list")';
                }
            });
            return false;
        });
    </script>
}


